<?php


	class Stock {
		private $order_quantity = 0;
		private $id;
		private $name;
		private $description;
		private $short_description;
		private $front_page_description;
		private $image;
		private $quantity;
		private $minimum_quantity;
		private $producer;
		private $price;
		private $promo;
		private $promo_price;
		private $category;
		private $front_page;


		public function __construct() {
		}

		public function Init(Array $stock) {
			$this->setId($stock["id"]);
			$this->setName($stock["name"]);

			if ($stock["description"] == NULL) {
				$this->setDescription("");
			} else {
				$this->setDescription($stock["description"]);
			}

			if ($stock["image"] == NULL) {
				$this->setImage("no-photo.jpg");
			} else {
				$this->setImage($stock["image"]);
			}

			if ($stock["promo"] == NULL) {
				$this->setPromo("");
			} else {
				$this->setPromo($stock["promo"]);
			}

			if ($stock["promo_price"] == NULL) {
				$this->setPromoPrice("");
			} else {
				$this->setPromoPrice($stock["promo_price"]);
			}

			if ($stock["front_page"] == NULL) {
				$this->setFrontPage("");
			} else {
				$this->setFrontPage($stock["front_page"]);
			}

			$this->setQuantity($stock["quantity_type"]);
			$this->setMinimumQuantity($stock["minimum_quantity"]);
			$this->setProducer($stock["producer"]);
			$this->setPrice($stock["price"]);
			$this->setCategory($stock["category"]);
		}


		public function setOrderQuantity($order_quantity) {
			$this->order_quantity = $order_quantity;
		}

		public function getOrderQuantity() {
			return $this->order_quantity;
		}

		public function setFrontPage($front_page) {
			$this->front_page = $front_page;
		}


		public function getFrontPage() {
			return $this->front_page;
		}

		public function setCategory($category) {
			$this->category = $category;
		}


		public function getCategory() {
			return $this->category;
		}


		public function setDescription($description) {
			$this->description = $description;
			$this->setShortDescription($description);
			$this->setFrontPageDescription($description);
		}


		public function getDescription() {
			return $this->description;
		}

		public function setFrontPageDescription($short_description) {
			$arr = explode(".", $short_description);
			$str = "";
			while (strlen($str) < 1000 && $arr) {
				$str = $str . array_shift($arr) . ". ";
			}
			$short_description            = $str;
			$this->front_page_description = $short_description;
		}


		public function getFrontPageDescription() {
			return $this->front_page_description;
		}

		public function setShortDescription($short_description) {
			$arr = explode(".", $short_description);
			$str = "";
			while (strlen($str) < 400 && $arr) {
				$str = $str . array_shift($arr) . ". ";
			}
			$short_description       = $str;
			$this->short_description = $short_description;
		}


		public function getShortDescription() {
			return $this->short_description;
		}

		public function setId($id) {
			$this->id = $id;
		}


		public function getId() {
			return $this->id;
		}


		public function setImage($image) {
			$this->image = $image;
		}


		public function getImage() {
			return $this->image;
		}


		public function setMinimumQuantity($minimum_quantity) {
			$this->minimum_quantity = $minimum_quantity;
		}


		public function getMinimumQuantity() {
			return $this->minimum_quantity;
		}


		public function setName($name) {
			$this->name = $name;
		}


		public function getName() {
			return $this->name;
		}


		public function setPrice($price) {
			$this->price = $price;
		}


		public function getPrice() {
			return $this->price;
		}


		public function setProducer($producer) {
			$this->producer = $producer;
		}


		public function getProducer() {
			return $this->producer;
		}


		public function setPromo($promo) {
			$this->promo = $promo;
		}


		public function getPromo() {
			return $this->promo;
		}


		public function setPromoPrice($promo_price) {
			$this->promo_price = $promo_price;
		}


		public function getPromoPrice() {
			return $this->promo_price;
		}

		public function setQuantity($quantity) {
			$this->quantity = $quantity;
		}


		public function getQuantity() {
			return $this->quantity;
		}


	}

?>